﻿namespace Community.Ssis.RankTransformUi
{
    using Microsoft.SqlServer.Dts.Pipeline.Design;
    using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
    using Microsoft.SqlServer.Dts.Runtime;
    using Microsoft.SqlServer.MessageBox;
    using System;
    using System.Windows.Forms;

    public class RankTransformUi : IDtsComponentUI
    {
        private IDTSComponentMetaData100 _componentMetadata;
        private IServiceProvider _serviceProvider;

        public void Delete(IWin32Window parentWindow)
        {
        }

        public bool Edit(IWin32Window parentWindow, Variables variables, Connections connections)
        {
            try
            {
                RankTransformUIForm form = new RankTransformUIForm();
                form.Initialize(this._componentMetadata, this._serviceProvider);
                if (form.ShowDialog(parentWindow) == DialogResult.OK)
                {
                    return true;
                }
            }
            catch (Exception exception)
            {
                new ExceptionMessageBox(exception).Show(parentWindow);
            }
            return false;
        }

        public void Help(IWin32Window parentWindow)
        {
        }

        public void Initialize(IDTSComponentMetaData100 componentMetadata, IServiceProvider serviceProvider)
        {
            this._componentMetadata = componentMetadata;
            this._serviceProvider = serviceProvider;
        }

        public void New(IWin32Window parentWindow)
        {
        }
    }
}

